/*
 * Copyright 2007-2008 Brian Cavalier
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package  org.bc.iterate.io;

import java.io.PrintWriter;
import org.bc.iterate.Closure;

/**
 * PrintlnClosure is a {@link org.bc.iterate.Closure} that prints items to the supplied {@link java.io.PrintWriter}.
 * 
 * @author Brian Cavalier
 */
public class PrintlnClosure implements Closure {
	private PrintWriter out;
	
	/**
	 * Creates a PrintlnClosure that will print to the supplied {@link java.io.PrintWriter}.
	 *
	 * @param out {@link java.io.PrintWriter} to which to print.
	 */
	public PrintlnClosure(PrintWriter out) {
		this.out = out;
	}
	
	/**
	 * Prints the supplied {@code Object} to the {@link java.io.PrintWriter} with which this
	 * PrintlnClosure was created.
	 *
	 * @param item {@code Object} to print.
	 */
	public void apply(Object item) {
		out.println(item);
	}
}